package com.examples;

public class Car {

	private String name;
	private int currentMiles;
	private int servicePeriod;
	int currentSpeed = 0;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getCurrentMiles() {
		return currentMiles;
	}

	public void setCurrentMiles(int currentMiles) {
		this.currentMiles = currentMiles;
	}

	public int getServicePeriod() {
		return servicePeriod;
	}

	public void setServicePeriod(int servicePeriod) {
		this.servicePeriod = servicePeriod;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + currentMiles;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + servicePeriod;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Car other = (Car) obj;
		if (currentMiles != other.currentMiles)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (servicePeriod != other.servicePeriod)
			return false;
		return true;
	}

	public int getCurrentSpeed() {
		return currentSpeed;
	}
	

	public void setCurrentSpeed(int currentSpeed) {
		this.currentSpeed = currentSpeed;
	}

	public void start() {
		System.out.println(" Car is started moving with 5 mph");
		if (currentSpeed != 0) {
			System.out.println("Car is already in move");
		} else {
			currentSpeed = +5;
		}
	}

	public void applySpeed() {
		System.out.println(" Car speed is increased by  5 mph - From Car class");
		this.currentSpeed += 5;
		System.out.println(" Current Speed is - " + currentSpeed);
	}

	public void applyBreak() {
		System.out.println(" Car speed is decresed by  5 mph -");
		currentSpeed -= 5;
		System.out.println(" Current Speed is - " + currentSpeed);
	}

	public void carDetails() {

		System.out.println("************** Name of the Car is " + this.name);
	}

}
